const path = require('path');

function resolve(dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  publicPath: './',
  lintOnSave: 'error',
  devServer: {
    port: 8080,
    proxy: {
      '/proxy': {
        target: 'https://hzz.schinta.com/els',
        secure: true,
        logLevel: 'debug',
        changeOrigin: true,
        pathRewrite: {
            '^/proxy': ''
        }
      }
    }
  },
  chainWebpack: (config) => {
    config.plugins.delete('prefetch');

    config.module.rule('svg').exclude.add(resolve('src/icons')).end();

    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]',
      });
  },
  productionSourceMap: process.env.NODE_ENV !== 'production',
  css: {
    loaderOptions: {
      sass: {
        // prependData: '@import "@/assets/styles/index.scss";',
      },
    },
  },
};
